/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.usercenter.model.entity;

import cn.hallele.mc.sdk.usercenter.common.enums.TenantStatusEnum;
import jakarta.persistence.*;
import lombok.*;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * hallele_ms_usercenter
 *
 * @author anle5
 * @since 2024/10/13 14:23
 */
@Setter
@Getter
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "uc_tenant")
public class TenantEntity implements Serializable {
    @Serial
    private static final long serialVersionUID = 2537116718218701079L;

    /**
     * 身份唯一标识
     * 生成策略: 从表key_generator中读取
     * name: TableGenerator唯一标识
     * pkColumnName：生成策略所对应键值的名称
     * pkColumnValue：键当前所生成的值，它的值将会随着每次创建累加
     * initialValue: 初始值
     * allocationSize: 递增至
     */
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "TenantEntity")
    @TableGenerator(name = "TenantEntity",
            table = "key_generator",
            pkColumnName = "gen_name",
            valueColumnName = "gen_value",
            pkColumnValue = "uc_tenant",
            initialValue = 1,
            allocationSize = 1
    )
    @Column(name = "id")
    private Integer id;

    /**
     * 租户名
     */
    @Column(name = "name")
    private String name;

    /**
     * 父节点id
     */
    @Column(name = "parent_id")
    private Integer parentId;

    /**
     * 父节点id路径
     */
    @Column(name = "tree_path")
    private String treePath;

    /**
     * 显示顺序
     */
    @Column(name = "sort")
    private Integer sort;

    /**
     * 状态(1:正常;0:禁用)
     */
    @Column(name = "status")
    private TenantStatusEnum status;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time")
    private Date updateTime;

    /**
     * 创建人id
     */
    @Column(name = "create_by")
    private Long createBy;

    /**
     * 修改人id
     */
    @Column(name = "update_by")
    private Long updateBy;
}
